//
//  JMMainView.m
//  VoluntaryStar
//
//  Created by ios on 15/8/17.
//  Copyright (c) 2015年 ios. All rights reserved.
//

#import "JMMainView.h"

@implementation JMMainView
@synthesize button = _button;

-(UIButton *)button{
    if(!_button){
        _button = [UIButton buttonWithType:UIButtonTypeContactAdd];
        [_button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        _button.tag = 100;
    }
    return _button;
}
-(void)buttonClick:(UIButton *)sender{
    if([self.delegate respondsToSelector:@selector(meunClick:)]){
        if(sender.tag == 100){
            self.type = JMMainViewXMenue;
        }
        [self.delegate meunClick:self];
    }else{
        @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[NSString stringWithFormat:@"%@",NSStringFromSelector(_cmd)] userInfo:nil];
    }
    
}

-(UITextField *)textFiel{
    if(!_textFiel){
        _textFiel = [[UITextField alloc]init];
        _textFiel.placeholder = @"请输入网址";
        _textFiel.borderStyle = UITextBorderStyleRoundedRect;
        _textFiel.clearButtonMode = UITextFieldViewModeWhileEditing;
    }
    return _textFiel;
}

-(void)setViewFrameWithInfo:(id)sender addSubView:(UIView *)superView{
    self.button.frame = self.buttonFrame;
    [superView addSubview:self.button];
    
    self.textFiel.frame = self.textFielFrame;
    [superView addSubview:self.textFiel];
}
@end

@implementation JMMainView(frame)
@dynamic buttonFrame;
@dynamic textFielFrame;


-(CGRect)buttonFrame{
    CGRect rect = CGRectMake(80,80, 80, 80);
    return rect;
}
-(CGRect) textFielFrame{
    return CGRectMake(20, 40, 280, 35);
}

@end
